Skip to content

Add example transaction golden test for each era#5799

Merged
koslambrou merged 2 commits into
masterfrom
koslambrou/golden-example-tx-each-era
May 13, 2026
Merged

Add example transaction golden test for each era#5799
koslambrou merged 2 commits into
masterfrom
koslambrou/golden-example-tx-each-era

Conversation

@koslambrou
Copy link
Copy Markdown
Contributor

@koslambrou koslambrou commented May 5, 2026

Description

Add Test.Cardano.Ledger.Core.Binary.Golden.goldenExampleEraTxCborSpec in cardano-ledger-core:testlib and generate the golden example transactions for each era.

goldenExampleEraTxCborSpec allows us to generate a Spec for
generating a golden/tx.cbor golden file out of some Tx provided as a
parameter.

Then, for each era's test-suite, we call this function to generate the
golden file using the example transaction we have defined for each era.

We also extended EraTest so that we don't need to manually call
getDataFileName in order to get the fullpath for each era's cabal
project.

We also create new Binary.Golden modules for Mary and Babbage (previously
they reused Allegra's and Alonzo's respectively).

Additionally, fix exampleDijkstraBasedTopTx to not add PlutusV4 scripts
to scriptTxWitsL: PlutusV4 is not included in Dijkstra's
transaction_witness_set CDDL, so those scripts were
silently dropped during serialization, causing a roundtrip failure.

Checklist

  • Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

Comment thread eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs
Comment thread eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Golden.hs
Comment thread eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Examples.hs
@koslambrou
Copy link
Copy Markdown
Contributor Author

koslambrou commented May 5, 2026

I wasn't 100% sure where to call goldenExampleEraTxCborSpec for each era. The test module structure is not consistent across eras.

A future PR would be required to organize the test modules so that each era follows the same pattern.

@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch 4 times, most recently from 145dd64 to 1515f46 Compare May 5, 2026 17:47
@koslambrou koslambrou marked this pull request as ready for review May 6, 2026 11:40
@koslambrou koslambrou requested a review from a team as a code owner May 6, 2026 11:40
Copy link
Copy Markdown
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase it on top of #5803 and use the new hierarchy for example golden tests

Comment thread eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs Outdated
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch from 1515f46 to 731c4a9 Compare May 6, 2026 17:40
@koslambrou koslambrou changed the base branch from master to lehins/reorganize-test-hierarchy May 6, 2026 17:41
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch 2 times, most recently from 2969def to 3ca2a75 Compare May 6, 2026 17:56
@lehins lehins force-pushed the lehins/reorganize-test-hierarchy branch 2 times, most recently from 615523d to 4c9b2c2 Compare May 7, 2026 10:19
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch 4 times, most recently from 4d6655d to 8f6be2b Compare May 11, 2026 20:02
@lehins lehins force-pushed the lehins/reorganize-test-hierarchy branch 3 times, most recently from 667c4cd to 9cbe932 Compare May 12, 2026 14:25
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch 3 times, most recently from d726379 to e00b05e Compare May 12, 2026 14:36
Base automatically changed from lehins/reorganize-test-hierarchy to master May 12, 2026 16:25
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch from e00b05e to 06606e0 Compare May 12, 2026 17:21
Copy link
Copy Markdown
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!
Thank you!

Comment thread eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs
@lehins
Copy link
Copy Markdown
Collaborator

lehins commented May 13, 2026

Needs a rebase and conflicts resolved, but other than that it is ready to go. 👍

…c` in cardano-ledger-core:testlib and generate the golden example transactions for each era.

`goldenExampleEraTxCborSpec` allows us to generate a `Spec` for
generating a `golden/tx.cbor` golden file out of some `Tx` provided as a
parameter.

Then, for each era's test-suite, we call this function to generate the
golden file using the example transaction we have defined for each era.

We also extended `EraTest` so that we don't need to manually call
`getDataFileName` in order to get the fullpath for each era's cabal
project.

We also create new `Binary.Golden` modules for Mary and Babbage (previously
they reused Allegra's and Alonzo's respectively, which used the wrong era's
example transactions).

Additionally, fix `exampleDijkstraBasedTopTx` to not add PlutusV4 scripts
to `scriptTxWitsL`: PlutusV4 is not included in Dijkstra's
`transaction_witness_set` CDDL, so those scripts were
silently dropped during serialization, causing a roundtrip failure.
@koslambrou koslambrou force-pushed the koslambrou/golden-example-tx-each-era branch from 06606e0 to 88e4fda Compare May 13, 2026 12:45
@koslambrou koslambrou enabled auto-merge May 13, 2026 12:46
@koslambrou koslambrou merged commit 3856b94 into master May 13, 2026
93 of 97 checks passed
@koslambrou koslambrou deleted the koslambrou/golden-example-tx-each-era branch May 13, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants